.class public Lcom/htc/android/footprints/provider/FootprintContentProvider;
.super Landroid/content/ContentProvider;
.source "FootprintContentProvider.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/htc/android/footprints/provider/FootprintContentProvider$DatabaseHelper;
    }
.end annotation


# static fields
.field public static final AUTGIRUTIES:Ljava/lang/String; = "com.htc.android.footprints.provider.FootprintContentProvider"

.field public static final DATABASE_NAME:Ljava/lang/String; = "footprints.db"

.field public static final DATABASE_VERSION:I = 0x24

.field private static final TAG:Ljava/lang/String; = "FootprintContentProvider"


# instance fields
.field private copyDBToSDRunnable:Ljava/lang/Runnable;

.field private mDataBase:Landroid/database/sqlite/SQLiteDatabase;

.field private mHandler:Landroid/os/Handler;

.field private mSubProviderMap:Ljava/util/HashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/HashMap",
            "<",
            "Landroid/net/Uri;",
            "Lcom/htc/android/footprints/provider/ISubProvider;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 27
    invoke-direct {p0}, Landroid/content/ContentProvider;-><init>()V

    .line 36
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iput-object v0, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mSubProviderMap:Ljava/util/HashMap;

    .line 172
    new-instance v0, Lcom/htc/android/footprints/provider/FootprintContentProvider$2;

    invoke-direct {v0, p0}, Lcom/htc/android/footprints/provider/FootprintContentProvider$2;-><init>(Lcom/htc/android/footprints/provider/FootprintContentProvider;)V

    iput-object v0, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->copyDBToSDRunnable:Ljava/lang/Runnable;

    return-void
.end method

.method static synthetic access$000(Lcom/htc/android/footprints/provider/FootprintContentProvider;)Ljava/util/HashMap;
    .locals 1
    .parameter "x0"

    .prologue
    .line 27
    iget-object v0, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mSubProviderMap:Ljava/util/HashMap;

    return-object v0
.end method

.method static synthetic access$100(Lcom/htc/android/footprints/provider/FootprintContentProvider;)Ljava/lang/Runnable;
    .locals 1
    .parameter "x0"

    .prologue
    .line 27
    iget-object v0, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->copyDBToSDRunnable:Ljava/lang/Runnable;

    return-object v0
.end method

.method static synthetic access$200(Lcom/htc/android/footprints/provider/FootprintContentProvider;)Landroid/os/Handler;
    .locals 1
    .parameter "x0"

    .prologue
    .line 27
    iget-object v0, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mHandler:Landroid/os/Handler;

    return-object v0
.end method

.method static synthetic access$300(Lcom/htc/android/footprints/provider/FootprintContentProvider;)Landroid/database/sqlite/SQLiteDatabase;
    .locals 1
    .parameter "x0"

    .prologue
    .line 27
    iget-object v0, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mDataBase:Landroid/database/sqlite/SQLiteDatabase;

    return-object v0
.end method


# virtual methods
.method public delete(Landroid/net/Uri;Ljava/lang/String;[Ljava/lang/String;)I
    .locals 5
    .parameter "url"
    .parameter "where"
    .parameter "whereArgs"

    .prologue
    .line 134
    invoke-virtual {p0, p1}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getISubProvider(Landroid/net/Uri;)Lcom/htc/android/footprints/provider/ISubProvider;

    move-result-object v1

    .line 135
    .local v1, provider:Lcom/htc/android/footprints/provider/ISubProvider;
    if-eqz v1, :cond_0

    .line 136
    invoke-interface {v1, p1, p2, p3}, Lcom/htc/android/footprints/provider/ISubProvider;->delete(Landroid/net/Uri;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 137
    .local v0, count:I
    invoke-virtual {p0}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    const/4 v3, 0x0

    invoke-virtual {v2, p1, v3}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    .line 138
    return v0

    .line 140
    .end local v0           #count:I
    :cond_0
    new-instance v2, Ljava/lang/IllegalArgumentException;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Unknown URL "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2
.end method

.method public getISubProvider(Landroid/net/Uri;)Lcom/htc/android/footprints/provider/ISubProvider;
    .locals 6
    .parameter "uri"

    .prologue
    const/4 v4, 0x3

    const-string v5, "/"

    .line 101
    invoke-virtual {p1}, Landroid/net/Uri;->toString()Ljava/lang/String;

    move-result-object v2

    const-string v3, "/"

    invoke-virtual {v2, v5}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v1

    .line 104
    .local v1, segment:[Ljava/lang/String;
    array-length v2, v1

    if-le v2, v4, :cond_0

    .line 105
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const/4 v3, 0x0

    aget-object v3, v1, v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "//"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const/4 v3, 0x2

    aget-object v3, v1, v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "/"

    invoke-virtual {v2, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    aget-object v3, v1, v4

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v0

    .line 109
    .local v0, result:Landroid/net/Uri;
    :goto_0
    const-string v2, "FootprintContentProvider"

    invoke-virtual {v0}, Landroid/net/Uri;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 110
    iget-object v2, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mSubProviderMap:Ljava/util/HashMap;

    invoke-virtual {v2, v0}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object p0

    .end local p0
    check-cast p0, Lcom/htc/android/footprints/provider/ISubProvider;

    return-object p0

    .line 107
    .end local v0           #result:Landroid/net/Uri;
    .restart local p0
    :cond_0
    move-object v0, p1

    .restart local v0       #result:Landroid/net/Uri;
    goto :goto_0
.end method

.method public getType(Landroid/net/Uri;)Ljava/lang/String;
    .locals 1
    .parameter "url"

    .prologue
    .line 115
    invoke-virtual {p0, p1}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getISubProvider(Landroid/net/Uri;)Lcom/htc/android/footprints/provider/ISubProvider;

    move-result-object v0

    invoke-interface {v0, p1}, Lcom/htc/android/footprints/provider/ISubProvider;->getType(Landroid/net/Uri;)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public insert(Landroid/net/Uri;Landroid/content/ContentValues;)Landroid/net/Uri;
    .locals 5
    .parameter "url"
    .parameter "initialValues"

    .prologue
    .line 120
    invoke-virtual {p0, p1}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getISubProvider(Landroid/net/Uri;)Lcom/htc/android/footprints/provider/ISubProvider;

    move-result-object v0

    .line 121
    .local v0, provider:Lcom/htc/android/footprints/provider/ISubProvider;
    if-eqz v0, :cond_0

    .line 122
    invoke-interface {v0, p1, p2}, Lcom/htc/android/footprints/provider/ISubProvider;->insert(Landroid/net/Uri;Landroid/content/ContentValues;)Landroid/net/Uri;

    move-result-object v1

    .line 123
    .local v1, rowUri:Landroid/net/Uri;
    invoke-virtual {p0}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    const/4 v3, 0x0

    invoke-virtual {v2, v1, v3}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    .line 125
    return-object v1

    .line 127
    .end local v1           #rowUri:Landroid/net/Uri;
    :cond_0
    new-instance v2, Ljava/lang/IllegalArgumentException;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Unknown URL "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2
.end method

.method public onCreate()Z
    .locals 9

    .prologue
    const/4 v8, 0x1

    .line 71
    new-instance v1, Lcom/htc/android/footprints/provider/CategoryProvider;

    invoke-direct {v1}, Lcom/htc/android/footprints/provider/CategoryProvider;-><init>()V

    invoke-virtual {p0, v1}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->registerSubProvider(Lcom/htc/android/footprints/provider/ISubProvider;)V

    .line 72
    new-instance v1, Lcom/htc/android/footprints/provider/FootprintsProvider;

    invoke-direct {v1}, Lcom/htc/android/footprints/provider/FootprintsProvider;-><init>()V

    invoke-virtual {p0, v1}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->registerSubProvider(Lcom/htc/android/footprints/provider/ISubProvider;)V

    .line 74
    new-instance v0, Lcom/htc/android/footprints/provider/FootprintContentProvider$DatabaseHelper;

    invoke-virtual {p0}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getContext()Landroid/content/Context;

    move-result-object v2

    const-string v3, "footprints.db"

    const/4 v4, 0x0

    const/16 v5, 0x24

    move-object v1, p0

    invoke-direct/range {v0 .. v5}, Lcom/htc/android/footprints/provider/FootprintContentProvider$DatabaseHelper;-><init>(Lcom/htc/android/footprints/provider/FootprintContentProvider;Landroid/content/Context;Ljava/lang/String;Landroid/database/sqlite/SQLiteDatabase$CursorFactory;I)V

    .line 76
    .local v0, dbHelper:Lcom/htc/android/footprints/provider/FootprintContentProvider$DatabaseHelper;
    invoke-virtual {v0}, Lcom/htc/android/footprints/provider/FootprintContentProvider$DatabaseHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    iput-object v1, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mDataBase:Landroid/database/sqlite/SQLiteDatabase;

    .line 77
    iget-object v1, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mSubProviderMap:Ljava/util/HashMap;

    invoke-virtual {v1}, Ljava/util/HashMap;->values()Ljava/util/Collection;

    move-result-object v1

    invoke-interface {v1}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v6

    .local v6, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v6}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_0

    invoke-interface {v6}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Lcom/htc/android/footprints/provider/ISubProvider;

    .line 78
    .local v7, provider:Lcom/htc/android/footprints/provider/ISubProvider;
    iget-object v1, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mDataBase:Landroid/database/sqlite/SQLiteDatabase;

    invoke-interface {v7, v1}, Lcom/htc/android/footprints/provider/ISubProvider;->setDB(Landroid/database/sqlite/SQLiteDatabase;)V

    goto :goto_0

    .line 80
    .end local v7           #provider:Lcom/htc/android/footprints/provider/ISubProvider;
    :cond_0
    new-instance v1, Landroid/os/Handler;

    invoke-direct {v1}, Landroid/os/Handler;-><init>()V

    iput-object v1, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mHandler:Landroid/os/Handler;

    .line 81
    invoke-virtual {p0}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    sget-object v2, Lcom/htc/android/footprints/provider/FootprintsProvider$FootprintColumns;->CONTENT_URI:Landroid/net/Uri;

    new-instance v3, Lcom/htc/android/footprints/provider/FootprintContentProvider$1;

    new-instance v4, Landroid/os/Handler;

    invoke-direct {v4}, Landroid/os/Handler;-><init>()V

    invoke-direct {v3, p0, v4}, Lcom/htc/android/footprints/provider/FootprintContentProvider$1;-><init>(Lcom/htc/android/footprints/provider/FootprintContentProvider;Landroid/os/Handler;)V

    invoke-virtual {v1, v2, v8, v3}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;)V

    .line 90
    iget-object v1, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mDataBase:Landroid/database/sqlite/SQLiteDatabase;

    if-nez v1, :cond_1

    const/4 v1, 0x0

    :goto_1
    return v1

    :cond_1
    move v1, v8

    goto :goto_1
.end method

.method public query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
    .locals 7
    .parameter "uri"
    .parameter "projection"
    .parameter "selection"
    .parameter "selectionArgs"
    .parameter "sortOrder"

    .prologue
    .line 162
    invoke-virtual {p0, p1}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getISubProvider(Landroid/net/Uri;)Lcom/htc/android/footprints/provider/ISubProvider;

    move-result-object v0

    .line 163
    .local v0, provider:Lcom/htc/android/footprints/provider/ISubProvider;
    if-eqz v0, :cond_0

    move-object v1, p1

    move-object v2, p2

    move-object v3, p3

    move-object v4, p4

    move-object v5, p5

    .line 164
    invoke-interface/range {v0 .. v5}, Lcom/htc/android/footprints/provider/ISubProvider;->query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v6

    .line 165
    .local v6, cursor:Landroid/database/Cursor;
    invoke-virtual {p0}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    invoke-interface {v6, v1, p1}, Landroid/database/Cursor;->setNotificationUri(Landroid/content/ContentResolver;Landroid/net/Uri;)V

    .line 166
    return-object v6

    .line 168
    .end local v6           #cursor:Landroid/database/Cursor;
    :cond_0
    new-instance v1, Ljava/lang/IllegalArgumentException;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "Unknown URL "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v1
.end method

.method public registerSubProvider(Lcom/htc/android/footprints/provider/ISubProvider;)V
    .locals 2
    .parameter "provider"

    .prologue
    .line 94
    invoke-virtual {p0}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getContext()Landroid/content/Context;

    move-result-object v0

    invoke-interface {p1, v0}, Lcom/htc/android/footprints/provider/ISubProvider;->setContext(Landroid/content/Context;)V

    .line 95
    iget-object v0, p0, Lcom/htc/android/footprints/provider/FootprintContentProvider;->mSubProviderMap:Ljava/util/HashMap;

    invoke-interface {p1}, Lcom/htc/android/footprints/provider/ISubProvider;->getBaseURI()Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {v0, v1, p1}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 98
    return-void
.end method

.method public update(Landroid/net/Uri;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I
    .locals 5
    .parameter "uri"
    .parameter "values"
    .parameter "where"
    .parameter "whereArgs"

    .prologue
    .line 148
    invoke-virtual {p0, p1}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getISubProvider(Landroid/net/Uri;)Lcom/htc/android/footprints/provider/ISubProvider;

    move-result-object v1

    .line 149
    .local v1, provider:Lcom/htc/android/footprints/provider/ISubProvider;
    if-eqz v1, :cond_0

    .line 150
    invoke-interface {v1, p1, p2, p3, p4}, Lcom/htc/android/footprints/provider/ISubProvider;->update(Landroid/net/Uri;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    move-result v0

    .line 151
    .local v0, count:I
    invoke-virtual {p0}, Lcom/htc/android/footprints/provider/FootprintContentProvider;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    const/4 v3, 0x0

    invoke-virtual {v2, p1, v3}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    .line 152
    return v0

    .line 154
    .end local v0           #count:I
    :cond_0
    new-instance v2, Ljava/lang/IllegalArgumentException;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Unknown URL "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2
.end method
